package com.etoak.controller;

import com.etoak.entity.Like;
import com.etoak.service.ILikeService;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.etoak.vo.ResultVo;
/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2024/7/12 21:00
 */
@RestController
@RequestMapping("like")
public class LikeController {
    @Autowired
    ILikeService iLikeService;

    @RequestMapping("/news/{id}/name/{username}")
    public ResultVo<Object> like(@PathVariable Integer id, @PathVariable String username){
        boolean b = iLikeService.addLike(id, username);
        Integer count = iLikeService.count(id);
        Like like = new Like(b,count);
        return ResultVo.success(like);
    }



}
